home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!tektronix!tekgen!tekred!games
- From: games@tekred.CNA.TEK.COM
- Newsgroups: comp.sources.games
- Subject: v06i032: cc2ps - convert carriage control to postscript
- Message-ID: <3749@tekred.CNA.TEK.COM>
- Date: 21 Mar 89 20:40:07 GMT
- Sender: billr@tekred.CNA.TEK.COM
- Lines: 178
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: John Chew <john@trigraph.uucp>
- Posting-number: Volume 6, Issue 32
- Archive-name: cc2ps
-
- [Here's a neat little script you may want to keep with the lp-posters
- previously posted. It lets you print them out on a PostScript
- device. -br]
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: README cc2ps cc2ps.1
- # Wrapped by billr@saab on Tue Mar 21 11:38:12 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(792 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis script (cc2ps) was written in order to display the line printer
- Xposters posted to comp.sources.games by Phillipe Bekaert
- X<SAAAA02%BLEKUL11.BITNET> (volume 6, issue 29). It has been tested
- Xunder 4.3 BSD on a VAX and A/UX 1.0 on a Macintosh IIx, with the
- XKorn and Bourne shells, and on an Apple LaserWriter II NTX and on
- Xan Apple LaserWriter Plus.
- X
- XInstall the script cc2ps and the man page cc2ps.1 wherever
- Xis appropriate to your system. If you use the -p option to
- Xcc2ps, you must have `lpr' in your search path.
- X
- XComments, flames and bug reports to...
- X
- Xjohn j. chew, iii phone: +1 416 425 3818 AppleLink: CDA0329
- Xtrigraph, inc., toronto, canada {uunet!utai!utcsri,utgpu,utzoo}!trigraph!john
- Xdept. of math., u. of toronto poslfit@{utorgpu.bitnet,gpu.utcs.utoronto.ca}
- END_OF_FILE
- if test 792 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'cc2ps' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cc2ps'\"
- else
- echo shar: Extracting \"'cc2ps'\" \(1333 characters\)
- sed "s/^X//" >'cc2ps' <<'END_OF_FILE'
- X#!/bin/sh
- X
- XPSBODY='
- X/ff{showpage hs vs scale lM tM translate 0 fs neg moveto} bind def
- X/lf{0 fs neg rmoveto currentpoint exch pop bM le{ff}if}bind def/s
- X{pop currentpoint 3 -1 roll show moveto}bind def/ccpr{/Courier
- Xfindfont setfont hs vs scale clippath pathbbox/tM exch def/rM exch def
- X/bM exch tM sub def/lM exch def lM tM translate rM lM sub( )stringwidth
- Xpop div 132 div hs mul dup/fs exch def/Courier findfont exch scalefont
- Xsetfont(%stdin)(r)file 132 string 0 0 moveto lf{1 index read{3 copy pop
- Xreadline{exch dup 48 eq{lf lf s}{dup 49 eq{ff s}{dup 43 eq{s}{dup 45 eq
- X{lf lf lf s}{lf s}ifelse}ifelse}ifelse}ifelse}{exit}ifelse}{exit}ifelse
- X}loop pop pop showpage}bind def ccpr'
- X
- XUSAGE="Usage: $0 [-6|-8] [-s scale] [-p] [file...]"
- X
- XLPI=6
- XPRINT=
- XSCALE=1.0
- X
- Xwhile [ $# != 0 ]
- X do
- X case $1 in
- X -6) LPI=6; shift ;;
- X -8) LPI=8; shift ;;
- X -s) SCALE=$2; shift; shift ;;
- X -p) PRINT=yup; shift ;;
- X -*) echo "$USAGE"; exit 1 ;;
- X *) break ;;
- X esac
- X done
- X
- XPSHEAD="%!
- X/hs $SCALE def/vs $SCALE 6 mul $LPI div def"
- X
- Xif [ $# = 0 ]
- X then
- X set foo -
- X shift
- X fi
- X
- Xif [ "$PRINT" ]
- X then
- X for file
- X do
- X {
- X echo "$PSHEAD"
- X echo "$PSBODY"
- X cat "$file"
- X } |lpr
- X done
- X else
- X echo "$PSHEAD"
- X echo "$PSBODY"
- X cat $1
- X shift
- X for file
- X do
- X echo "1"
- X cat "$file"
- X done
- X fi
- END_OF_FILE
- if test 1333 -ne `wc -c <'cc2ps'`; then
- echo shar: \"'cc2ps'\" unpacked with wrong size!
- fi
- chmod +x 'cc2ps'
- # end of 'cc2ps'
- fi
- if test -f 'cc2ps.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cc2ps.1'\"
- else
- echo shar: Extracting \"'cc2ps.1'\" \(1600 characters\)
- sed "s/^X//" >'cc2ps.1' <<'END_OF_FILE'
- X.TH cc2ps 1 Local
- X.SH NAME
- Xcc2ps \- convert line printer carriage control to PostScript
- X.SH SYNOPSIS
- X.B cc2ps
- X[
- X.B \-6
- X|
- X.B \-8
- X] [
- X.B \-s
- Xscale ] [
- X.B \-p
- X] [file...]
- X.SH DESCRIPTION
- XFiles formatted using line printer carriage control characters
- Xare converted to a form suitable for output to a PostScript device.
- X.PP
- XInput files should consist of newline-separated records. Each
- Xrecord should start with a carriage control character, which should
- Xbe followed by at most 132 printing characters. Carriage control
- Xcharacters `+', ` ', `0', '-' indicate that respectively 0, 1, 2 or
- X3 lines should be skipped before printing the current line. Carriage
- Xcontrol character `1' causes a form feed (showpage) to be generated
- Xbefore printing the current line.
- X.PP
- XBy default, output is scaled to make 132 characters take up the
- Xwidth of the current clipping area. An image that is too large
- Xto fit on one page will be split as necessary.
- X.PP
- XThe `\-6' and `\-8' option choose between simulating the aspect
- Xratio for a six lines per inch printer or for an eight lines per
- Xinch printer. Six is the default.
- X.PP
- XThe `\-s' option gives a scaling factor for images. The default
- Xvalue of 1.0 makes 132 characters fit the current page width.
- XGreater values will cause characters to be dropped off the right
- Xside of the page. Lesser values will reduce long images to fit
- Xonto a single page.
- X.PP
- XThe `\-p' option pipes the resulting PostScript code to
- X.IR lpr (1).
- X.SH AUTHOR
- XJohn J. Chew <poslfit@gpu.utcs.UToronto.CA>, 20 March 1989
- X.SH BUGS
- XNone known, but contact the author (see above) if any are found.
- END_OF_FILE
- if test 1600 -ne `wc -c <'cc2ps.1'`; then
- echo shar: \"'cc2ps.1'\" unpacked with wrong size!
- fi
- # end of 'cc2ps.1'
- fi
- echo shar: End of shell archive.
- exit 0
-